package com.xiaocikuai.smallchunks.config;

import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;

import java.io.FileInputStream;

public class WeChatPayUtil {
//    private static final String merchantId = WxPayAppConfig.mchId;
//    private static final String merchantSerialNumber = WxPayAppConfig.merchantSerialNumber;
//    private static final String merchantPrivateKeyPath = WxPayAppConfig.privateKeyPath;
//    private static final String apiV3Key = WxPayAppConfig.apiV3key;
//
//    public static void main(String[] args) throws Exception {
//        // 初始化 HttpClient
//        CloseableHttpClient httpClient = WechatPayHttpClientBuilder.create()
//                .withMerchant(merchantId, merchantSerialNumber, PemUtil.loadPrivateKey(new FileInputStream(merchantPrivateKeyPath)))
//                .withValidator(response -> true) // 初次获取平台证书时跳过应答签名验证
//                .build();
//
//        // 获取平台证书
//        URIBuilder uriBuilder = new URIBuilder("https://api.mch.weixin.qq.com/v3/certificates");
//        HttpGet httpGet = new HttpGet(uriBuilder.build());
//        httpGet.addHeader("Accept", "application/json");
//
//        CloseableHttpResponse response = httpClient.execute(httpGet);
//        String bodyAsString = EntityUtils.toString(response.getEntity());
//        System.out.println(bodyAsString);
//    }
}
